package com.easyctrl.ldy.util;

import java.util.LinkedList;

import android.app.Activity;

public class ExitApp {
	private static ExitApp instance;
	private LinkedList<Activity> activities;
	private ExitApp(){
		activities = new LinkedList<Activity>();
	}
	
	public static ExitApp getInstance(){
		if(instance == null){
			instance = new ExitApp();
		}
		return instance;
	}
	public void addActivity(Activity activity){
		activities.offer(activity);
	}
	public void exit(){
		Activity activity;
		while((activity = activities.poll()) != null){
			activity.finish();
		}
		System.exit(0);
	}
}
